module.exports = app => {
    const DataTypes = app.Sequelize;
    const Model = app.model.define('sys_config_attr', {
        id: {
            type: DataTypes.INTEGER(11).UNSIGNED,
            allowNull: false,
            primaryKey: true,
            autoIncrement: true,
        },
        configName: {
            type: DataTypes.STRING(60),
            allowNull: false,
        },
        field: {
            type: DataTypes.STRING(60),
            allowNull: false,
            comment: "字段名称"
        },
        name: {
            type: DataTypes.STRING(60),
            allowNull: true,
            comment: "字段描述"
        },
        type: {
            type: DataTypes.STRING(60),
            allowNull: true,
            enum: ['TEXT', 'SELECT', 'RADIO'],
            comment: "字段类型"
        },
        options: {
            type: DataTypes.STRING(60),
            allowNull: true,
            comment: "可选项"
        },
        isRequired: {
            type: DataTypes.BOOLEAN,
            allowNull: true,
            comment: "是否必填"
        },
        defaultValue: {
            type: DataTypes.STRING(300),
            allowNull: true,
            comment: "默认值"
        },
        helpText: {
            type: DataTypes.STRING(60),
            allowNull: true,
            comment: "帮助信息"
        },
        isOccupyOneline: {
            type: DataTypes.STRING(60),
            allowNull: true,
            comment: "是否占据一行"
        },
        order: {
            type: DataTypes.STRING(60),
            allowNull: true,
            comment: "排序，数字越小，排序越靠前"
        },
        is_delete: {
            type: DataTypes.INTEGER(1).UNSIGNED,
            allowNull: false,
            defaultValue: '0',
            comment: '是否删除，0->存在，1->删除'
        },
    }, {
        tableName: 'sys_config_attr',
        comment: "系统配置"
    });

    Model.sync({ alter: true });
    
    return Model;
};
